package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: WangHongKun
 * @Date: 2022/9/22 16:58
 * @Email: 2028911483@qq.com
 * @Phone: 18683977706
 */

@Mapper
public interface DishMapper {
    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return
     */
    //TODO
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 新增菜品
     * @param dish
     */

    @AutoFill(value = OperationType.INSERT)
    void addDish(Dish dish);

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    List<DishVO> PageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 新建路径
     * @param id
     * @param newPath
     */
    void SetNewPath(Long id,String newPath);

    /**
     * 批量删除
     * @param ids
     */
    void DeleteAll(List<Long> ids);

    /**
     * BYid 查询菜品
     * @param id
     * @return
     */
    @Select("select * from  dish where  id =#{id}")
    Dish getById(Long id);

    /**
     * 停售起售
     * @param id
     * @param status
     */
    @Update("updateNumber  dish set status = #{status} where id =#{id} ")
    void StartOrStop(Long id , Integer status);

    /**
     * 修改菜品
     * @param dish
     */
    @AutoFill(value = OperationType.UPDATE)
    void Update(Dish dish);

    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    DishVO getDTOById(Long id);

    /**
     * 根据分类id查询菜品
     * @param categoryId
     * @return
     */
    @Select("select  * from  dish where category_id= #{categoryId}")
    List<Dish>  getByCategoryId(Long  categoryId);



    List<DishVO>  getVoByCategoryId(Long  categoryId);

    @Select("select  count(id)  from dish where status=#{status} ")
    Integer getCountByStatus(Integer status);
}
